package com.tanhua.manage.controller;

import com.tanhua.manage.service.MessageServiceImpl;
import com.tanhua.manage.vo.LogQueryParam;
import com.tanhua.manage.vo.PageResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 寒
 * @date 2021/6/9
 * @TIME:9:41
 */
@RestController
@RequestMapping("/manage")
@Slf4j
public class LogController {
    @Autowired
    MessageServiceImpl messageServiceImpl;
    @GetMapping("logs")
    public ResponseEntity<PageResult> queryLogs(LogQueryParam logQueryParam) {
        System.out.println(logQueryParam);
        try {
            PageResult pageResult = messageServiceImpl.queryLogs(logQueryParam);
            if (null != pageResult) {
                return ResponseEntity.ok(pageResult);
            }
        } catch (Exception e) {
            log.error("查询日志列表出错~ ", e);
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
    }
}
